﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class FinanceSalesDetailRptQuery : BasePage
    {
        protected Button btnSearch;
        protected CheckBox ckbByDate;
        protected CheckBox ckbShowDate;
        protected DropDownList ddlCustomerID;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlSkuID;
        protected HtmlForm F15320;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected Label lblCustomerID;
        protected Label lblEndDatetime;
        protected Label lblMsg;
        protected Label lblOwnerID;
        protected Label lblSkuID;
        protected Label lblStartDatetime;
        protected HtmlLink mycss;
        protected Label one1;
        protected TextBox txtCustomerID;
        protected TextBox txtEndDatetime;
        protected TextBox txtOwnerID;
        protected TextBox txtSkuID;
        protected TextBox txtStartDatetime;

        protected void btnExport_Click(object sender, EventArgs e)
        {
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (this.ckbByDate.Checked)
            {
                DateTime startTime = DateTime.Parse(this.StartDatetime);
                if (DateTime.Parse(this.EndDatetime).Subtract(startTime).Days > 0x1f)
                {
                    this.lblMsg.Text = "按照日期显示,只能查询31天内的数据请修改日期时间段!";
                }
                else
                {
                    base.Server.Transfer("FinanceSalesDetailByDateRptList.aspx", false);
                }
            }
            else
            {
                base.Server.Transfer("FinanceSalesDetailRptList.aspx", false);
            }
        }

        private void InitDropDownLists()
        {
            this.txtStartDatetime.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.txtEndDatetime.Text = DateTime.Now.ToString("yyyy-MM-dd");
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlSkuID, 0);
            base.InitQueryDDL(this.ddlCustomerID, 0);
            base.SetDefaultOwner(this.txtOwnerID);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
            }
            this.lblMsg.Text = "";
        }

        public string CustomerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCustomerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCustomerID.Text.Trim(), this.ddlCustomerID.SelectedValue);
                }
                return "";
            }
        }

        public string EndDatetime
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDatetime.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtEndDatetime.Text).ToString("yyyy-MM-dd") + " 23:59:59");
                }
                return "9999-12-31 23:59:59";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string ShowDate
        {
            get
            {
                if (this.ckbShowDate.Checked)
                {
                    return "Y";
                }
                return "N";
            }
        }

        public string SkuID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtSkuID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtSkuID.Text.Trim(), this.ddlSkuID.SelectedValue);
                }
                return "";
            }
        }

        public string StartDatetime
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStartDatetime.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtStartDatetime.Text).ToString("yyyy-MM-dd") + " 00:00:00");
                }
                return "2000-01-01 00:00:00";
            }
        }
    }
}

